package com.zhu.ttwords.view.adapter;

import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.util.SparseArray;
import android.view.View;
import android.view.ViewGroup;

import com.zhu.ttwords.R;
import com.zhu.ttwords.bean.WordBean;
import com.zhu.ttwords.model.IStudyModel;
import com.zhu.ttwords.view.activity.IStudyActivity;
import com.zhu.ttwords.view.listener.StudyListener;
import com.zhu.ttwords.view.widget.StudyView;

import java.util.List;


public class StudyAdapter extends PagerAdapter {

    List<Object> mData;
    int mode;

    Context mContext;

    public StudyAdapter(Context context, List<Object> mData) {
        super();
        this.mContext = context;
        this.mData = mData;
        mode = IStudyActivity.MODE_STUDY;
    }
    public StudyAdapter(Context context, List<Object> mData,int mode) {
        super();
        this.mContext = context;
        this.mData = mData;
        this.mode = mode;
    }

    @Override
    public int getCount() {
        return mData.size();
    }

    @Override
    public boolean isViewFromObject(View view, Object o) {
        return view == o;
    }
    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView((View) object);
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        WordBean bean = (WordBean)mData.get(position);
        StudyView view = new StudyView(mContext);
        view.setBean(bean, true);
        container.addView(view);
       return view;
    }
}
